<template>
  <van-tabbar route>
    <van-tabbar-item to="/" icon="home-o">home</van-tabbar-item>
    <van-tabbar-item to="/car" icon="cart-o">car</van-tabbar-item>
    <van-tabbar-item to="/login" icon="manager-o" v-if="!token"
      >login</van-tabbar-item
    >
    <van-tabbar-item to="/login" icon="manager-o" v-else>User</van-tabbar-item>
  </van-tabbar>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useUsrInfoStore } from "@/stores/userinfo";
import type { Ref } from "vue";

const token: Ref<string> = ref("");
const store = useUsrInfoStore();
onMounted(() => {
  if (!token.value && localStorage.getItem("userToken")) {
    store.userToken = localStorage.getItem("userToken") as string;
    token.value = store.getUserToken;
  }
});
</script>

<style lang="scss" scoped>
</style>